﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="card_deputy.aspx.cs" Inherits="backmanage_cardsystem_card_deputy" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>新手卡类别</title>
    <script type="text/javascript" src="../js/jquery1.6.2.js"></script>
	<script type="text/javascript" src="../external/jquery.bgiframe-2.1.2.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.core.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.widget.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.mouse.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.button.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.draggable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.position.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.resizable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.dialog.js"></script> 
	<script type="text/javascript" src="../js/jquery.effects.core.js"></script> 
	<script type="text/javascript" src="../js/jquery.ajax.upfile.js"></script>
	<script type="text/javascript" src="../js/jquery.ingrid.js"></script>
	<link rel="Stylesheet" href="../css/ingrid.css" />
    <link rel="stylesheet" href="../css/demos.css" />
    <link rel="stylesheet" href="../css/jquery.ui.all.css" />
    <script type="text/javascript">
    $(function(){
    $("#dialog-form").dialog("destory");
          var name = $( "#name" ),
				    activation=$("#activation"),
				    money=$("#money"),
				    info=$("#info"),
				    allFields = $( [] ).add( name ).add(activation).add(money).add(info),
				    tips = $( ".validateTips" );
                function updateTips(t)
                {
                  tips.text(t)	
                      .addClass("ui-state-highlight");
                  setTimeout(function(){
                      tips.removeClass("ui-state-highlight",1500);
                  },500);
                }
                function checkEmpty(e,n)
                {
                  if(e.val().length>0){
                     return true;}
                  else{
                     e.addClass("ui-state-error");
                     updateTips(n+"不能为空.");
                     return false;
                     }
                }
                function CardAdd()
                {
                  var n=$("#name").val(),g=$("#game").find("option:selected").attr("value"),t=$("#type").find("option:selected").attr("value"),
                        u=$("#isuse").find("option:selected").attr("value"),s=$("#isstate").find("option:selected").attr("value"),
                        w=$("#isshow").find("option:selected").attr("value"),a=$("#activation").val(),m=$("#money").val(),i=$("#info").val();
                  $.ajax({
                        async:false,
                        url:'../API/A_Card.aspx',
                        type:'POST',
                        data:{edit:'add',n:n,g:g,t:t,u:u,s:s,w:w,a:a,m:m,i:i},
                        dataType:'json',
                        success:function(data)
                        {
                           alert(data.msg);
                        }
                  });
                }
                $("#dialog-form").dialog({
                     autoOpen:false,
                     height:400,
                     width:600,
                     modal:true,
                     buttons:{
                               "提交":function(){
                                   var flag=true;
                                   allFields.removeClass("ui-state-error");
                                       
                                   flag=flag && checkEmpty(name,"新手卡名称");
                                   flag=flag && checkEmpty(activation,"激活地址");
                                   flag=flag && checkEmpty(money,"使用点数");
                                   flag=flag && checkEmpty(info,"新手卡描述");

                                   if(flag)
                                   {
                                        CardAdd();
                                        $(this).dialog("close");
                                        
                                   }
                               },
                               "取消":function(){
                                   $(this).dialog("close");
                               },
                             },
                      close:function(){allFields.val("").removeClass("ui-state-error");
                      },
          });
          function GetGameList()
          {
            $.ajax({
                 async:false,
                 url:'../API/A_Card.aspx',
                 type:'POST',
                 data:{edit:'gamelist'},
                 success:function(msg)
                 {
                   $("#game").append(msg);
                 }
            });
          }
          
          function GetCardList()
          {
            $.ajax({
               async:false,
               url:'../API/A_Card.aspx',
               type:'POST',
               data:{edit:'list'},
               success:function(msg)
               {
                 $("#cardlist tbody").text("");
                 $("#cardlist tbody").append(msg);
               }
            })
          }
          function SetTable(){
		  $("#cardlist").tableSorter({
		        sortColumn: 'name',			
		        sortClassAsc: 'headerSortUp',		
		        sortClassDesc: 'headerSortDown',	
		        headerClass: 'header',
		  });}
          $("#create-user").button().click(function(){$("#dialog-form").dialog("open");});
          $(document).ready(function(){
             GetCardList();
             GetGameList();
             SetTable();
          })
    })
    </script>
    <style type="text/css">
        body { font-size: 62.5%; }
		label, input { display:block;}
		input.text { margin-bottom:12px; width:95%; padding: .4em; }
		fieldset { padding:0; border:0; margin-top:25px; }
		h1 { font-size: 1.2em; margin: .6em 0; }
		div#users-contain { width: 350px; margin: 20px 0; }
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
		.ui-dialog .ui-state-error { padding: .3em; }
    	.validateTips { border:1px transparent solid; padding: 0.3em; }
		.validateTips input{border:1}
		.text{border:1}
		div#img-size{ width:200px}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    新手卡类别管理
    <a id="create-user">添加新手卡类别</a>
    <table id="cardlist" name="cardlist" >
      <thead>
        <tr>
          <th>游戏名称</th>
          <th>新手卡名称</th>
          <th>新手卡描述</th>
          <th>卡类型</th>
          <th>激活地址</th>
          <th>卡数量</th>
          <th>兑换点数</th>
          <th>是否可用</th>
          <th>状态</th>
          <th>是否显示</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      </tbody>
      <tfoot>
         <tr>
          <td colspan="11">
            一共100页 第一页
          </td>
        </tr>
      </tfoot>
    </table>
    <div id="dialog-form" title="添加新手卡类别">
    <p class="validateTips">填写要添加的新手卡的分类信息.</p> 
    <fieldset>
    <table style="width:550px">
      <tr>
      <td colspan="5">
           <label for="name">新手卡名称</label>
           <input type="text" name="name" id="name" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        </tr>
        <tr>
        <td>
           <label for="game">游戏名称</label>
           <select id="game">
            <option value="0">所有游戏</option>
           </select>
        </td>
        <td>
           <label for="type">卡类型</label>
           <select id="type">
             <option value="0">新手卡</option>
             <option value="1">活动卡</option>
           </select>
        </td>
        <td>
           <label for="isuse">是否可用</label>
           <select id="isuse">
             <option value="T">可用</option>
             <option value="F">不可用</option>
           </select>
        </td>
        <td>
           <label for="isstate">状态</label>
           <select id="isstate">
             <option value="T">可用</option>
             <option value="F">不可用</option>
           </select>
        </td>
        <td>
           <label for="isshow">是否显示</label>
           <select id="isshow">
             <option value="T">显示</option>
             <option value="F">不显示</option>
           </select>
        </td>
      </tr>
      <tr>
        <td colspan="3">
           <label for="activation">激活地址</label>
           <input type="text" name="activation" id="activation" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        <td colspan="2">
           <label for="money">使用点数</label>
           <input type="text" name="money" id="money" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        </tr>
        <tr>
        <td colspan="5">
           <label for="info">新手卡描述</label>
           <textarea name="info" id="info" class="text ui-widget-content ui-corner-all" rows="4" cols="90"></textarea>
        </td>
      </tr>
    </table>
    </fieldset>
    </div>
    </div>
    </form>
</body>
</html>
